package school.valon.constantes;

import school.valon.dto.PaymentTypeDto;

public enum EnumPaymentType {
	CASH(1, "cash"), CREDIT_CARD(2, "creadit card"),
	TRNASFERT(3, "money transfert"), CHEQUE(4, "cheque");

	private int typeId;
	private String caption;
	private EnumPaymentType(int typeId, String caption) {
		this.typeId = typeId;
		this.caption = caption;
	}

	public int getTypeId() {
		return this.typeId;
	}
	public String getCaption() {
		return this.caption;
	}

	public static EnumPaymentType getPaymentTypeById(int typeId) {
		for(EnumPaymentType enumTypeIt : EnumPaymentType.values()) {
			if (enumTypeIt.typeId == typeId) {
				return enumTypeIt;
			}
		}
		return null;
	}

	public PaymentTypeDto getPaymentTypeDto() {
		PaymentTypeDto paymentTypeDto = new PaymentTypeDto();
		paymentTypeDto.setPaymentTypeId(this.typeId);
		return paymentTypeDto;
	}
}
